<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script src="../js/jquery/1.x/jquery.js?v=1"></script>
    <script src="../layui/layui.js?v=1" charset="utf-8"></script>
    <link rel="stylesheet" href="../layui/css/layui.css?v=1" media="all">
    <link rel="stylesheet" href="../css/indexboard.css?v=2" media="all">
    <link rel="stylesheet" href="../css/public.css?v=1" media="all">
    <style>.layui-header{height:80px;}.exit-btn{cursor: pointer}</style>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">

        <div class="layui-logo">
            <img src="../img/logo2.png">
        </div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-layout-right">
            <li class="layui-nav-item header-userinfo">
                <div class="top">
                    <p class="username">韩三区 欢迎登录</p>
                    <p class="exit-btn">
                        <img src="../img/tuichu.png">
                        退出
                    </p>
                </div>
                <div class="bottom">
                    <span class="user_center_name">系统升级测试医院</span>
                    <span>|</span>
                    <span class="dept_name">内分泌内科</span>
                </div>
            </li>
            <li class="layui-nav-item touxiang">
                <img src="../img/touxiang2.png">
            </li>
            <div class="clear"></div>
        </ul>

    </div>
    <div class="title">
        <p>首页</p>
    </div>
    <div class="container">

        <ul class="nav-list">
            <!--<li>
                <a href="javascript:;" data-nav_id="1" data-href="./patient/add.html">
                    <img src="../img/xinbinglidengji.png">
                </a>
            </li>
            <li>
                <a href="javascript:;" data-nav_id="2" data-href="./patient/list.html">
                    <img src="../img/bingliguanli.png">
                </a>
            </li>
            <li>
                <a href="javascript:;" data-nav_id="3" data-href="./follow/list.html">
                    <img src="../img/suifangguanli.png">
                </a>
            </li>
            <li>
                <a href="javascript:;" data-nav_id="4" data-href="./tongji.html">
                    <img src="../img/tongjifenxi.png">
                </a>
            </li>-->
        </ul>
        <div class="to-menu" style="display:none;">
            <a href="./index.html"><button>切换到菜单</button></a>
        </div>
    </div>
    <div class="footer"></div>
</div>
</body>
<script src="../js/public.js"></script>
<script src="../js/config.js"></script>
<script src="../js/function.js"></script>
<script>
    $(document).ready(function(){
        window.onload=function(){
            setContainerHeight();
        }
        window.onresize=function(){
            setContainerHeight();
        }
        function setContainerHeight(){
            var height = $(document).height();
            var container_height = height-100-100-140;
            $('.container').css('height',container_height);
        }
        ajax_get(configUrl.getMenuList,'',(res)=>{
            console.log(res.data);
            $.each(res.data,function (index,item) {
                if(item.id == 2) {
                    var str1 = '<li>' +
                        '<a href="javascript:;" data-nav_id="1" data-href="./patient/V1_1/add.html">' +
                        '<img src="../img/xinbinglidengji.png">' +
                        '</a>' +
                        '</li>';
                    var str = '<li>' +
                        '<a href="javascript:;" data-nav_id="2" data-href="./patient/list.html">' +
                        '<img src="../img/bingliguanli.png">' +
                        '</a>' +
                        '</li>';
                    $('.nav-list').append(str1);
                    $('.nav-list').append(str);
                }
                if(item.id == 3) {
                    var str = '<li>' +
                        '<a href="javascript:;" data-nav_id="3" data-href="./follow/list.html">' +
                        '<img src="../img/suifangguanli.png">' +
                        '</a>' +
                        '</li>';
                    $('.nav-list').append(str);
                }
                if(item.id == 4) {
                    var str = '<li>' +
                        '<a href="javascript:;" data-nav_id="4" data-href="./tongji.html">' +
                        '<img src="../img/tongjifenxi.png">' +
                        '</a>' +
                        '</li>'
                    $('.nav-list').append(str);
                }

            })
        })
        layui.use(['element','layer'],function(){

            //退出登录
            $('.exit-btn').click(function(){
                window.localStorage.clear();
                layer.msg('退出成功',{icon:1,time:1000},function(){
                    window.location.href='./login.html';
                });
            })
            var userInfo = JSON.parse(getLocalStorage('userInfo'));
            console.log(userInfo)
            $('.username').text(userInfo.user_name + ' 欢迎登录');
            $('.user_center_name').text(userInfo.center_name);
            $('.dept_name').text(userInfo.dept_name);
            $('.touxiang img').attr('src', userInfo.photo);
            $('.center_name').text(userInfo.center_name);

            $('.nav-list').on('click','li a',function(){
                var nav_id = $(this).attr('data-nav_id');
                var href = $(this).attr('data-href');
                saveLocalStorage('nav_id',nav_id);
                saveLocalStorage('curr_href',href);
                window.location.href='./index.html';
            })
        })
    })
</script>
</html>